﻿/**
*    Copyright (C) 2008  Chase Kernan 
*    chase.kernan@gmail.com
*
*    This program is free software: you can redistribute it and/or modify
*    it under the terms of the GNU General Public License as published by
*    the Free Software Foundation, either version 3 of the License, or
*    (at your option) any later version.
*
*    This program is distributed in the hope that it will be useful,
*    but WITHOUT ANY WARRANTY; without even the implied warranty of
*    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*    GNU General Public License for more details.
*
*    You should have received a copy of the GNU General Public License
*    along with this program.  If not, see <http://www.gnu.org/licenses/>.
* 
*/

package com.chasekernan.hxnova.componenteditor;

import com.chasekernan.hxnova.componenteditor.details.ArmorPanel;
import com.chasekernan.hxnova.componenteditor.details.BombPanel;
import com.chasekernan.hxnova.componenteditor.details.HullPanel;
import com.chasekernan.hxnova.core.components.Armor;
import com.chasekernan.hxnova.core.components.BeamWeapon;
import org.aswing.DefaultBoundedRangeModel;
import org.aswing.ext.Form;
import org.aswing.Component;
import org.aswing.ext.FormRow;
import org.aswing.JAdjuster;
import com.chasekernan.hxnova.componenteditor.details.BeamWeaponPanel;
import org.aswing.JCheckBox;
import org.aswing.JPanel;
import org.aswing.border.EmptyBorder;
import org.aswing.Insets;
import com.chasekernan.hxnova.componenteditor.details.BombPanel;
import org.aswing.border.TitledBorder;
import com.chasekernan.hxnova.componenteditor.details.CargoPodPanel;
import com.chasekernan.hxnova.componenteditor.details.ComputerPanel;
import com.chasekernan.hxnova.componenteditor.details.DefensePanel;
import com.chasekernan.hxnova.componenteditor.details.MissilePanel;
import com.chasekernan.hxnova.componenteditor.details.ScannerPanel;
import com.chasekernan.hxnova.componenteditor.details.ShieldPanel;
import com.chasekernan.hxnova.componenteditor.details.StarScannerPanel;

class DetailsPanel extends Form {
    
    public var allInputs : Array<Dynamic>;
    
    public function new() { super(); }
    
    public function loadFromComponent() {}
    
    public function saveToComponent() {}

    public static function getDetailsPanel(type : String) : DetailsPanel {
        var detailsClass = Type.resolveClass("com.chasekernan.hxnova.componenteditor.details." + type + "Panel");
        
        if (detailsClass == null) return null;
        
        var form : DetailsPanel = untyped Type.createInstance(detailsClass, []);
        
        if (form == null) return null;
        
        form.setBorder(new EmptyBorder(new TitledBorder(new EmptyBorder(null, new Insets(5, 5, 5, 5)), "Details -- " + type), new Insets(5, 5, 5, 5)));
        
        return form;
    }
    
    //haXe doesnt have the ... function parameter, so this is a quick fix.
    public function addRowHaxe(c1 : org.aswing.Component, c2 : org.aswing.Component, c3 : org.aswing.Component) {
        append(createRow([c1, c2, c3]));
    }
    
    public static function createIntAdjuster(min : Int, max : Int) : JAdjuster {
        var adj = new JAdjuster();
        adj.setMinimum(min);
        adj.setMaximum(max);
        adj.setValue(min);
        return adj;
    }
}
